/**
 * a class implementing the mathematical equivalent of a two dimensional circle
 * @author nadav cohen,matan monitz
 *
 */
public class Circle implements Shape {
	private Point center;
	private double radius;
	/**
	 * a constructor for circle
	 * @param center an instance of Point representing the center of the circle. must be initialized.
	 * @param radius the radius of the circle
	 */
	public Circle(Point center,double radius)
	{
		if (center == null)
			throw new RuntimeException("input object uninitialized");
		this.radius = radius;
		this.center = new Point(center);
	}
	/**
	 * a copy constructor for circle utilizing deep copy semantics
	 * @param c an instance of Circle to be copied. must be initialized
	 */
	public Circle(Circle c)
	{
		if (c == null)
			throw new RuntimeException("input object uninitialized");
		this.center = c.getCenter();
		this.radius = c.getRadius();
	}
	/**
	 * a getter for the radius of the circle
	 * @return the value of the radius field
	 */
	public double getRadius()
	{
		return this.radius;
	}
	/**
	 * a getter for the center point of the circle
	 * @return a new instance (copy) of the point representing the center of the circle.
	 */
	public Point getCenter()
	{
		return new Point(this.center);
	}
	/**
	 * a logical comparison of two circles
	 * @param other the object to be compared with
	 * @return true if other is an instance of circle, the radius is the same and the center points are logically equal.
	 */
	public boolean equals(Object other)
	{
	
		if(other instanceof Circle)
		{
			return (this.radius==((Circle)other).getRadius()) && ((Circle)other).getCenter().equals(this.center);
		}
		else
			return false;
	}
	/**
	 * calculate the perimeter of the circle
	 * @return the perimeter of the circle
	 */
	public double getPerimeter() {
		return 2*this.radius*Math.PI;
		
	}

	/** 
	 * calculate the area of the circle.
	 * @return the area of the circle.
	 */
	public double getArea() {
		return Math.pow(radius, 2)*Math.PI;
		
	}

	/**
	 * moves the circle by calling move on the center point
	 * @param p an instance of Point. must be initialized.
	 */
	public void move(Point p) {
		center.move(p);

	}

	/**
	 * checks if a given point is inside the circle
	 * @param p the point to be checked.
	 * @return true if the point is inside the circle.
	 */
	public boolean contains(Point p) {
		
		return p.distance(center)<=radius;
	}

}
